﻿using System.Linq;
using LinFu.IoC.Configuration;

namespace CoreEx.Database.Metadata.Tests
{
    [Implements(typeof(ICustomMetadataProvider))]
    public class SampleCustomMetadataProvider : ICustomMetadataProvider
    {
        public void Configure(IMetadataRepository metadataRepository)
        {
            var ordersView = metadataRepository.Tables.Where(t => t.TableName == "Orders Qry").FirstOrDefault();
            var customerTable = metadataRepository.Tables.Where(t => t.TableName == "Customers").FirstOrDefault();

            ordersView.DefinePrimaryKey("OrderID");
            ordersView.DefineForeignKey(customerTable, new[] { "CustomerID" });
        }
    }
}
